﻿namespace AC.ExtendedRenderer.Toolkit
{
    using ComponentFactory.Krypton.Toolkit;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Media;
    using System.Windows.Forms;

    public class KryptonMessageBox : KryptonForm
    {
        public KryptonButton btnAbort;
        public KryptonButton btnCancel;
        public KryptonButton btnIgnore;
        public KryptonButton btnNo;
        public KryptonButton btnOK;
        public KryptonButton btnRetry;
        public KryptonButton btnYes;
        private IContainer components;
        private ImageList ilIcons;
        private Panel panel1;
        public PictureBox pbIcon;
        public Label rtbMessage;

        public KryptonMessageBox()
        {
            this.InitializeComponent();
        }

        private void btnAbort_Click(object sender, EventArgs e)
        {
            base.DialogResult = DialogResult.Abort;
            base.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            base.DialogResult = DialogResult.Cancel;
            base.Close();
        }

        private void btnIgnore_Click(object sender, EventArgs e)
        {
            base.DialogResult = DialogResult.Ignore;
            base.Close();
        }

        private void btnNo_Click(object sender, EventArgs e)
        {
            base.DialogResult = DialogResult.No;
            base.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            base.DialogResult = DialogResult.OK;
            base.Close();
        }

        private void btnRetry_Click(object sender, EventArgs e)
        {
            base.DialogResult = DialogResult.Retry;
            base.Close();
        }

        private void btnYes_Click(object sender, EventArgs e)
        {
            base.DialogResult = DialogResult.Yes;
            base.Close();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            ComponentResourceManager manager = new ComponentResourceManager(typeof(KryptonMessageBox));
            this.btnOK = new KryptonButton();
            this.btnIgnore = new KryptonButton();
            this.btnAbort = new KryptonButton();
            this.btnRetry = new KryptonButton();
            this.btnYes = new KryptonButton();
            this.btnNo = new KryptonButton();
            this.btnCancel = new KryptonButton();
            this.rtbMessage = new Label();
            this.ilIcons = new ImageList(this.components);
            this.pbIcon = new PictureBox();
            this.panel1 = new Panel();
            this.panel1.SuspendLayout();
            base.SuspendLayout();
            this.btnOK.DialogResult = DialogResult.OK;
            this.btnOK.Location = new Point(0x63, 14);
            this.btnOK.Name = "btnOK";
            this.btnOK.Size = new Size(90, 0x19);
            this.btnOK.TabIndex = 0;
            this.btnOK.Text = "OK";
            this.btnOK.Values.ExtraText = "";
            this.btnOK.Values.Image = null;
            this.btnOK.Values.ImageStates.ImageCheckedNormal = null;
            this.btnOK.Values.ImageStates.ImageCheckedPressed = null;
            this.btnOK.Values.ImageStates.ImageCheckedTracking = null;
            this.btnOK.Values.Text = "OK";
            this.btnOK.Visible = false;
            this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
            this.btnIgnore.DialogResult = DialogResult.Ignore;
            this.btnIgnore.Location = new Point(0xc2, 14);
            this.btnIgnore.Name = "btnIgnore";
            this.btnIgnore.Size = new Size(90, 0x19);
            this.btnIgnore.TabIndex = 2;
            this.btnIgnore.Text = "Ignore";
            this.btnIgnore.Values.ExtraText = "";
            this.btnIgnore.Values.Image = null;
            this.btnIgnore.Values.ImageStates.ImageCheckedNormal = null;
            this.btnIgnore.Values.ImageStates.ImageCheckedPressed = null;
            this.btnIgnore.Values.ImageStates.ImageCheckedTracking = null;
            this.btnIgnore.Values.Text = "Ignore";
            this.btnIgnore.Visible = false;
            this.btnIgnore.Click += new System.EventHandler(this.btnIgnore_Click);
            this.btnAbort.DialogResult = DialogResult.Abort;
            this.btnAbort.Location = new Point(4, 14);
            this.btnAbort.Name = "btnAbort";
            this.btnAbort.Size = new Size(90, 0x19);
            this.btnAbort.TabIndex = 3;
            this.btnAbort.Text = "Abort";
            this.btnAbort.Values.ExtraText = "";
            this.btnAbort.Values.Image = null;
            this.btnAbort.Values.ImageStates.ImageCheckedNormal = null;
            this.btnAbort.Values.ImageStates.ImageCheckedPressed = null;
            this.btnAbort.Values.ImageStates.ImageCheckedTracking = null;
            this.btnAbort.Values.Text = "Abort";
            this.btnAbort.Visible = false;
            this.btnAbort.Click += new System.EventHandler(this.btnAbort_Click);
            this.btnRetry.DialogResult = DialogResult.Retry;
            this.btnRetry.Location = new Point(0x63, 14);
            this.btnRetry.Name = "btnRetry";
            this.btnRetry.Size = new Size(90, 0x19);
            this.btnRetry.TabIndex = 4;
            this.btnRetry.Text = "Retry";
            this.btnRetry.Values.ExtraText = "";
            this.btnRetry.Values.Image = null;
            this.btnRetry.Values.ImageStates.ImageCheckedNormal = null;
            this.btnRetry.Values.ImageStates.ImageCheckedPressed = null;
            this.btnRetry.Values.ImageStates.ImageCheckedTracking = null;
            this.btnRetry.Values.Text = "Retry";
            this.btnRetry.Visible = false;
            this.btnRetry.Click += new System.EventHandler(this.btnRetry_Click);
            this.btnYes.DialogResult = DialogResult.Yes;
            this.btnYes.Location = new Point(4, 14);
            this.btnYes.Name = "btnYes";
            this.btnYes.Size = new Size(90, 0x19);
            this.btnYes.TabIndex = 5;
            this.btnYes.Text = "Yes";
            this.btnYes.Values.ExtraText = "";
            this.btnYes.Values.Image = null;
            this.btnYes.Values.ImageStates.ImageCheckedNormal = null;
            this.btnYes.Values.ImageStates.ImageCheckedPressed = null;
            this.btnYes.Values.ImageStates.ImageCheckedTracking = null;
            this.btnYes.Values.Text = "Yes";
            this.btnYes.Visible = false;
            this.btnYes.Click += new System.EventHandler(this.btnYes_Click);
            this.btnNo.DialogResult = DialogResult.No;
            this.btnNo.Location = new Point(0x63, 14);
            this.btnNo.Name = "btnNo";
            this.btnNo.Size = new Size(90, 0x19);
            this.btnNo.TabIndex = 6;
            this.btnNo.Text = "No";
            this.btnNo.Values.ExtraText = "";
            this.btnNo.Values.Image = null;
            this.btnNo.Values.ImageStates.ImageCheckedNormal = null;
            this.btnNo.Values.ImageStates.ImageCheckedPressed = null;
            this.btnNo.Values.ImageStates.ImageCheckedTracking = null;
            this.btnNo.Values.Text = "No";
            this.btnNo.Visible = false;
            this.btnNo.Click += new System.EventHandler(this.btnNo_Click);
            this.btnCancel.DialogResult = DialogResult.Cancel;
            this.btnCancel.Location = new Point(0xc2, 14);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new Size(90, 0x19);
            this.btnCancel.TabIndex = 7;
            this.btnCancel.Text = "Cancel";
            this.btnCancel.Values.ExtraText = "";
            this.btnCancel.Values.Image = null;
            this.btnCancel.Values.ImageStates.ImageCheckedNormal = null;
            this.btnCancel.Values.ImageStates.ImageCheckedPressed = null;
            this.btnCancel.Values.ImageStates.ImageCheckedTracking = null;
            this.btnCancel.Values.Text = "Cancel";
            this.btnCancel.Visible = false;
            this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
            this.rtbMessage.Location = new Point(12, 2);
            this.rtbMessage.Name = "rtbMessage";
            this.rtbMessage.Size = new Size(0x10a, 0x48);
            this.rtbMessage.TabIndex = 8;
            this.rtbMessage.TextAlign = ContentAlignment.MiddleLeft;
            this.ilIcons.ImageStream = (ImageListStreamer) manager.GetObject("ilIcons.ImageStream");
            this.ilIcons.TransparentColor = Color.Transparent;
            this.ilIcons.Images.SetKeyName(0, "Information.png");
            this.ilIcons.Images.SetKeyName(1, "Question.png");
            this.ilIcons.Images.SetKeyName(2, "Error.png");
            this.ilIcons.Images.SetKeyName(3, "Warning.png");
            this.ilIcons.Images.SetKeyName(4, "Stop.png");
            this.ilIcons.Images.SetKeyName(5, "empty.png");
            this.pbIcon.InitialImage = (Image) manager.GetObject("pbIcon.InitialImage");
            this.pbIcon.Location = new Point(30, 0x16);
            this.pbIcon.Name = "pbIcon";
            this.pbIcon.Size = new Size(0x20, 0x20);
            this.pbIcon.TabIndex = 9;
            this.pbIcon.TabStop = false;
            this.panel1.BackColor = Color.WhiteSmoke;
            this.panel1.Controls.Add(this.btnCancel);
            this.panel1.Controls.Add(this.btnOK);
            this.panel1.Controls.Add(this.btnIgnore);
            this.panel1.Controls.Add(this.btnYes);
            this.panel1.Controls.Add(this.btnAbort);
            this.panel1.Controls.Add(this.btnRetry);
            this.panel1.Controls.Add(this.btnNo);
            this.panel1.Dock = DockStyle.Bottom;
            this.panel1.Location = new Point(0, 0x4d);
            this.panel1.Name = "panel1";
            this.panel1.Size = new Size(290, 0x34);
            this.panel1.TabIndex = 10;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            this.BackColor = Color.White;
            base.ClientSize = new Size(290, 0x81);
            base.Controls.Add(this.panel1);
            base.Controls.Add(this.pbIcon);
            base.Controls.Add(this.rtbMessage);
            base.FormBorderStyle = FormBorderStyle.FixedDialog;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "KryptonMessageBox";
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "KryptonMessageBox";
            base.TopMost = true;
            this.panel1.ResumeLayout(false);
            base.ResumeLayout(false);
        }

        private void ResetButtonsLocation()
        {
            this.btnYes.Location = new Point(3, 14);
            this.btnNo.Location = new Point(0x62, 14);
            this.btnCancel.Location = new Point(0xc1, 14);
            this.btnOK.Location = new Point(0x62, 14);
            this.btnAbort.Location = new Point(3, 14);
            this.btnRetry.Location = new Point(0x62, 14);
            this.btnIgnore.Location = new Point(0xc1, 14);
            this.btnYes.Visible = false;
            this.btnNo.Visible = false;
            this.btnCancel.Visible = false;
            this.btnOK.Visible = false;
            this.btnAbort.Visible = false;
            this.btnRetry.Visible = false;
            this.btnIgnore.Visible = false;
            this.pbIcon.Visible = true;
            this.pbIcon.Image = this.ilIcons.Images[5];
        }

        public static DialogResult Show(string Message)
        {
            return Show(Message, "");
        }

        public static DialogResult Show(object sender, string Message)
        {
            return Show(Message);
        }

        public static DialogResult Show(string Message, string Caption)
        {
            KryptonMessageBox box = new KryptonMessageBox();
            box.Text = Caption;
            box.rtbMessage.Text = Message;
            box.btnOK.Visible = true;
            box.pbIcon.Visible = false;
            SystemSounds.Exclamation.Play();
            box.ShowDialog();
            return box.DialogResult;
        }

        public static DialogResult Show(object sender, string Message, string Caption)
        {
            return Show(Message, Caption);
        }

        public static DialogResult Show(string Message, string Caption, MessageBoxButtons Buttons)
        {
            return Show(Message, Caption, Buttons, MessageBoxIcon.None);
        }

        public static DialogResult Show(string Message, MessageBoxButtons Buttons, MessageBoxIcon Icon)
        {
            return Show(Message, "", Buttons, Icon);
        }

        public static DialogResult Show(object sender, string Message, string Caption, MessageBoxButtons Buttons)
        {
            return Show(Message, Caption, Buttons);
        }

        public static DialogResult Show(object Sender, string Message, MessageBoxButtons Buttons, MessageBoxIcon Icon)
        {
            return Show(Message, Buttons, Icon);
        }

        public static DialogResult Show(string Message, string Caption, MessageBoxButtons Buttons, MessageBoxIcon Icon)
        {
            KryptonMessageBox box = new KryptonMessageBox();
            box.Text = Caption;
            box.rtbMessage.Text = Message;
            switch (Buttons)
            {
                case MessageBoxButtons.OK:
                    box.btnOK.Visible = true;
                    break;

                case MessageBoxButtons.OKCancel:
                    box.btnOK.Visible = true;
                    box.btnCancel.Visible = true;
                    box.btnOK.Location = new Point(0x3b, 14);
                    box.btnCancel.Location = new Point(0x9f, 14);
                    break;

                case MessageBoxButtons.AbortRetryIgnore:
                    box.btnAbort.Visible = true;
                    box.btnRetry.Visible = true;
                    box.btnIgnore.Visible = true;
                    break;

                case MessageBoxButtons.YesNoCancel:
                    box.btnYes.Visible = true;
                    box.btnNo.Visible = true;
                    box.btnCancel.Visible = true;
                    break;

                case MessageBoxButtons.YesNo:
                    box.btnYes.Visible = true;
                    box.btnNo.Visible = true;
                    box.btnYes.Location = new Point(0x3b, 14);
                    box.btnNo.Location = new Point(0x9f, 14);
                    break;

                case MessageBoxButtons.RetryCancel:
                    box.btnRetry.Visible = true;
                    box.btnCancel.Visible = true;
                    box.btnRetry.Location = new Point(0x3b, 14);
                    box.btnCancel.Location = new Point(0x9f, 14);
                    break;
            }
            Point point = new Point(box.rtbMessage.Location.X, box.rtbMessage.Location.Y);
            Size size = new Size(box.rtbMessage.Size.Width, box.rtbMessage.Size.Height);
            switch (Icon)
            {
                case MessageBoxIcon.Question:
                    box.pbIcon.Image = SystemIcons.Question.ToBitmap();
                    box.rtbMessage.Location = new Point(box.rtbMessage.Location.X + 0x3f, box.rtbMessage.Location.Y);
                    box.rtbMessage.Width = box.rtbMessage.Size.Width - 0x3f;
                    SystemSounds.Question.Play();
                    goto Label_0428;

                case MessageBoxIcon.Exclamation:
                    box.pbIcon.Image = SystemIcons.Exclamation.ToBitmap();
                    box.rtbMessage.Location = new Point(box.rtbMessage.Location.X + 0x3f, box.rtbMessage.Location.Y);
                    box.rtbMessage.Width = box.rtbMessage.Size.Width - 0x3f;
                    SystemSounds.Exclamation.Play();
                    goto Label_0428;

                case MessageBoxIcon.Asterisk:
                    box.pbIcon.Image = SystemIcons.Asterisk.ToBitmap();
                    box.rtbMessage.Location = new Point(box.rtbMessage.Location.X + 0x3f, box.rtbMessage.Location.Y);
                    box.rtbMessage.Width = box.rtbMessage.Size.Width - 0x3f;
                    SystemSounds.Asterisk.Play();
                    break;

                case MessageBoxIcon.None:
                    box.pbIcon.Visible = false;
                    box.pbIcon.Image = SystemIcons.Question.ToBitmap();
                    goto Label_0428;

                case MessageBoxIcon.Hand:
                    box.pbIcon.Image = SystemIcons.Error.ToBitmap();
                    box.rtbMessage.Location = new Point(box.rtbMessage.Location.X + 0x3f, box.rtbMessage.Location.Y);
                    box.rtbMessage.Width = box.rtbMessage.Size.Width - 0x3f;
                    SystemSounds.Exclamation.Play();
                    goto Label_0428;
            }
        Label_0428:
            box.ShowDialog();
            box.rtbMessage.Location = point;
            box.rtbMessage.Size = size;
            box.ResetButtonsLocation();
            return box.DialogResult;
        }

        public static DialogResult Show(object Sender, string Message, string Caption, MessageBoxButtons Buttons, MessageBoxIcon Icon)
        {
            return Show(Message, Caption, Buttons, Icon);
        }
    }
}

